package io.github.harmonly.skyblock.command;

import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import io.github.harmonly.skyblock.game.pets.Pet;
import io.github.harmonly.skyblock.game.pets.PetEntity;
import org.bukkit.inventory.ItemStack;

public class TestCommand implements SBCommand {

    @Override
    public String name() {
        return "test";
    }

    @Override
    public void register() {
        new CommandAPICommand("test")
                .withPermission(CommandPermission.OP)
                .executesPlayer(((sender, args) -> {
                    ItemStack item = sender.getInventory().getItemInMainHand();
                    Pet pet = Pet.from(item);
                    if (pet != null) {
                        new PetEntity(sender, pet);
                    }
                }))
                .register();
    }

    @Override
    public void unregister() {
        CommandAPI.unregister("test");
    }
}
